home *** CD-ROM | disk | FTP | other *** search
/ The Sunday Times: The Month 2004 August / The Sunday Times - The Month 2004-08.iso / pc / engine / modules / text_audio.swf / scripts / frame_1 / DoAction.as
Encoding:
Text File  |  2004-06-24  |  6.6 KB  |  245 lines

  1. function loadImage(mc, node, extrapath)
  2. {
  3.    var _loc3_ = extrapath;
  4.    if(_loc3_ == null)
  5.    {
  6.       _loc3_ = "";
  7.    }
  8.    var strDefaultPath = Tardis.ASSETS_FOLDER + "images/" + Tardis.ActiveSection.id + "/";
  9.    var _loc1_ = node.firstChild.nodeValue;
  10.    var _loc2_ = node.attributes.path;
  11.    if(_loc2_ != null)
  12.    {
  13.       _loc1_ = _loc2_ + _loc1_;
  14.    }
  15.    else
  16.    {
  17.       _loc1_ = strDefaultPath + _loc3_ + _loc1_;
  18.    }
  19.    if(strPathPrefix == null)
  20.    {
  21.       strPathPrefix = "";
  22.    }
  23.    mc.loadMovie(strPathPrefix + _loc1_);
  24. }
  25. function addLink(mc)
  26. {
  27.    Links[mc.link] = mc;
  28. }
  29. function getMCfromLink(Item)
  30. {
  31.    var _loc1_ = Item;
  32.    if(Links[_loc1_] == null)
  33.    {
  34.       var _loc2_ = [];
  35.       while(_loc1_ != sideMenu.ItemHome)
  36.       {
  37.          _loc2_.unshift(_loc1_._name.split("_").pop());
  38.          _loc1_ = _loc1_._parent._parent;
  39.       }
  40.       var _loc3_ = _loc2_.join("/");
  41.       Links[_loc1_] = Links[_loc3_];
  42.    }
  43.    return Links[_loc1_];
  44. }
  45. function removeLinkListener()
  46. {
  47.    Tardis.sideMenu.EB.removeListener(this);
  48. }
  49. function interrupt()
  50. {
  51.    fade(this.snd,0);
  52. }
  53. function resume()
  54. {
  55.    trackUp(mc_t_1);
  56. }
  57. function init()
  58. {
  59.    build();
  60. }
  61. function build()
  62. {
  63.    TEXT_POS = 5;
  64.    var _loc3_ = Tardis.ActiveSection.id;
  65.    var _loc1_ = Tardis.Colors;
  66.    strSECTION_COLOR = _loc1_.getString(_loc3_);
  67.    SECTION_COLOR = _loc1_.getHex(_loc3_);
  68.    SECTION_COLOR50 = _loc1_.getString(_loc3_ + "50");
  69.    DEFAULT_COLOR = _loc1_.getHex("default");
  70.    DEFAULT_COLOR50 = _loc1_.getString("default50");
  71.    IMAGE_PATH = nodeData.attributes.imagepath;
  72.    ndTracks = nodeData.byName("track");
  73.    strTrackpath = Tardis.ASSETS_FOLDER + ndTracks.attributes.path;
  74.    if(nodeData.byName("title") != null || nodeData.byName("title2") != null || nodeData.byName("title3") != null)
  75.    {
  76.       var _loc2_ = "<FONT COLOR=\"" + strSECTION_COLOR + "\">" + nodeData.byName("title").getText() + " </FONT>";
  77.       _loc2_ += "<FONT COLOR=\"" + SECTION_COLOR50 + "\">" + nodeData.byName("title2").getText() + "</FONT>";
  78.       _loc2_ += "<FONT COLOR=\"" + SECTION_COLOR50 + "\">" + nodeData.byName("title3").getText() + "</FONT>";
  79.       titleFF.htmlText = _loc2_;
  80.       titleFF.resize();
  81.       titleFF._y = TEXT_POS;
  82.       TEXT_POS += titleFF._height - 4;
  83.    }
  84.    if(nodeData.byName("byline") != null)
  85.    {
  86.       title2FF.htmlText = nodeData.byName("byline").getText();
  87.       title2FF.resize();
  88.       title2FF.textColor = DEFAULT_COLOR;
  89.       title2FF._y = TEXT_POS;
  90.       TEXT_POS += title2FF._height - 9;
  91.    }
  92.    if(nodeData.byName("body") != null)
  93.    {
  94.       bodyFF.htmlText = parseBoldTags(nodeData.byName("body").getText());
  95.       bodyFF.textColor = DEFAULT_COLOR;
  96.       bodyFF.resize();
  97.       bodyFF._y = TEXT_POS;
  98.       TEXT_POS += bodyFF._height;
  99.    }
  100.    if(nodeData.byName("image") != null)
  101.    {
  102.       loadImage(mc_images,nodeData.byName("image"),IMAGE_PATH);
  103.    }
  104.    trackLabelFF.htmlText = ndTracks.byName("label").getText();
  105.    trackLabelFF.resize();
  106.    trackLabelFF.textColor = DEFAULT_COLOR;
  107.    trackLabelFF._y = 385 - trackLabelFF._height + 5;
  108.    mc_timebar._y = trackLabelFF._y - 5;
  109.    mc_controls._y = mc_timebar._y - 17;
  110.    _visible = true;
  111.    playSound();
  112.    onComplete();
  113. }
  114. function parseBoldTags(str)
  115. {
  116.    var _loc1_ = str;
  117.    var _loc2_ = _loc1_.indexOf("<b>");
  118.    if(_loc2_ != -1)
  119.    {
  120.       var _loc3_ = _loc1_.indexOf("</b>");
  121.       var word = _loc1_.substring(_loc2_ + 3,_loc3_);
  122.       var beginning = _loc1_.substring(0,_loc2_);
  123.       var end = _loc1_.substring(_loc3_ + 4);
  124.       return beginning + "<font face=\'FranklinGotURWTDem\'>" + word + "</font>" + parseBoldTags(end);
  125.    }
  126.    return _loc1_;
  127. }
  128. function playSound()
  129. {
  130.    createEmptyMovieClip("mc_sound",Tardis.depth++);
  131.    snd = new Sound(mc_sound);
  132.    var _loc1_ = strPathPrefix + strTrackpath + ndTracks.byName("file").firstChild.nodeValue;
  133.    snd.loadSound(_loc1_,false);
  134.    snd.onLoad = function()
  135.    {
  136.       this.start();
  137.       mc_timebar.play();
  138.       mc_controls.gotoAndStop("active");
  139.    };
  140. }
  141. function resumeSound(posToStart)
  142. {
  143.    var _loc1_ = posToStart;
  144.    if(_loc1_ == null)
  145.    {
  146.       sndPos = snd.position / 1000;
  147.    }
  148.    else
  149.    {
  150.       sndPos = _loc1_;
  151.    }
  152.    if(_loc1_ == 0)
  153.    {
  154.       trackUp(currentTrack);
  155.    }
  156.    else
  157.    {
  158.       snd.start(sndPos,1);
  159.    }
  160. }
  161. function pauseSound()
  162. {
  163.    snd.stop();
  164. }
  165. function stopSound()
  166. {
  167.    snd.stop();
  168.    delete snd;
  169.    mc_sound.removeMovieClip();
  170. }
  171. function startTimebar()
  172. {
  173.    var _loc1_ = this;
  174.    mc_timebar.onEnterFrame = function()
  175.    {
  176.       var _loc1_ = this;
  177.       if(_loc1_.DRAGGING == true)
  178.       {
  179.          var _loc2_ = _loc1_.mc_handle._x / _loc1_.AVAIL_WIDTH;
  180.          var f = Math.round(_loc2_ * _loc1_._parent.snd.duration);
  181.       }
  182.       else if(_loc1_._parent.mc_controls._currentFrame == 20)
  183.       {
  184.          _loc2_ = _loc1_._parent.snd.position / _loc1_._parent.snd.duration;
  185.          if(_loc2_ < 1)
  186.          {
  187.             _loc1_.mc_handle._x = _loc2_ * _loc1_.AVAIL_WIDTH;
  188.          }
  189.       }
  190.    };
  191. }
  192. function clearUp()
  193. {
  194.    mc_timebar.onEnterFrame = null;
  195. }
  196. function setWidth(nm)
  197. {
  198.    mc_timebar.mc_track._width = nm;
  199.    mc_timebar.AVAIL_WIDTH = nm - mc_timebar.mc_handle._width;
  200. }
  201. function setTarget(mc)
  202. {
  203.    mc_timebar.TARGET = snd;
  204. }
  205. Links = {};
  206. Tardis.sideMenu.EB.addListener(this);
  207. _visible = false;
  208. onReady();
  209. this.onUnload = function()
  210. {
  211.    interrupt();
  212.    removeLinkListener();
  213.    this.onUnload = null;
  214. };
  215. mc_timebar.mc_handle.btn.onPress = function()
  216. {
  217.    var _loc1_ = this;
  218.    _loc1_._parent.startDrag(false,0,0,_loc1_._parent._parent.AVAIL_WIDTH,0);
  219.    _loc1_._parent._parent.DRAGGING = true;
  220.    _loc1_._parent._parent._parent.soundPause();
  221. };
  222. mc_timebar.mc_handle.btn.onRelease = mc_timebar.mc_handle.btn.onReleaseOutside = function()
  223. {
  224.    var _loc1_ = this;
  225.    _loc1_.posToStart = math.ceil(_loc1_._parent._parent.mc_handle._x / _loc1_._parent._parent.AVAIL_WIDTH * _loc1_._parent._parent.TARGET.duration / 1000);
  226.    if(_loc1_._parent._parent.mc_controls._currentFrame != 30)
  227.    {
  228.       _loc1_._parent._parent._parent.soundResume(_loc1_.posToStart);
  229.    }
  230.    _loc1_._parent.stopDrag();
  231.    _loc1_._parent._parent.DRAGGING = false;
  232. };
  233. mc_timebar.mc_handle.btn.onRollOver = function()
  234. {
  235.    var _loc1_ = this;
  236.    _loc1_.myColor = new Color(_loc1_._parent.scrubbaMC);
  237.    _loc1_.myColor.setRGB(_loc1_._parent._parent._parent.SECTION_COLOR);
  238. };
  239. mc_timebar.mc_handle.btn.onRollOut = function()
  240. {
  241.    var _loc1_ = this;
  242.    _loc1_.myColor = new Color(_loc1_._parent.scrubbaMC);
  243.    _loc1_.myColor.setRGB(_loc1_._parent._parent._parent.DEFAULT_COLOR);
  244. };
  245.